package com.rbcs.base.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.systop.common.modules.security.user.model.User;
import com.systop.core.model.BaseModel;

/**
 * 外币币种管理
 * @author ShangHua
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "currency")
public class Currency extends BaseModel {

	// 主键ID
	private Integer id;

	// 币种名称
	private String name;

	// 创建人
	private User creator;
	
	// 创建时间
	private Date createTime;

	private Set<ExchangeRate> exchangeRates = new HashSet<ExchangeRate>(0);

	public Currency() {
	}

	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "Id", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "creator_id")
	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}

	@JoinColumn(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "currency")
	public Set<ExchangeRate> getExchangeRates() {
		return exchangeRates;
	}

	public void setExchangeRates(Set<ExchangeRate> exchangeRates) {
		this.exchangeRates = exchangeRates;
	}

}
